//
//  NSObject+Binding.h
//  LAMapBasicDemo
//
//  Created by 罗亮富 on 2018/1/8.
//  Copyright © 2018年 2Bulu. All rights reserved.
//

#import <Foundation/Foundation.h>



typedef enum {
    ObjectBindWeak = 0,
    ObjectBindStrong,
    ObjectBindCopy,
}ObjectBindPolicy;


@interface NSObject (Binding)

//这些接口的效率都不是特别高效,线程安全; obj可以是除WeakReference以外的任何实例对象
-(void)bindObject:(nonnull id)obj forKey:(nonnull NSString *)key policy:(ObjectBindPolicy)policy;
-(nullable id)bindedObjectForKey:(nonnull NSString *)key;

-(void)enumerateBindedKeysAndObjectsUsingBlock:(void ( ^)( NSString *key, id obj, BOOL *stop))block;

-(void)removeBindedObjectForKey:(nonnull NSString *)key;
-(void)removeAllBindedObjects;//清除所有缓存的关联数据

@end
